package com.clb.studyproject.utils

import android.content.Context

/**
 * 单位转换工具类
 */
object ConversionUtils {

    fun dp2px(context: Context,dipValue:Float): Int {
        val density = context.resources.displayMetrics.density
        return (density*dipValue+0.5f).toInt()
    }

    fun px2dp(context: Context,pxValue:Float): Int {
        val density = context.resources.displayMetrics.density
        return(pxValue/density+0.5).toInt()
    }
}